from pyspark import SparkContext
from pyspark.ml.classification import LogisticRegressionModel
from pyspark.ml.linalg import Vectors
from pyspark.sql import SparkSession

sc = SparkContext.getOrCreate()
ss = SparkSession(sparkContext=sc)

model = LogisticRegressionModel.load("file:///Users/sonto/Workspace/Rimi/P1902/spark_example/ml_lesson1")
assert isinstance(model, LogisticRegressionModel)
while True:
    pt=input("Enter point: x,y")
    point = pt.split(",")
    print("Predicating: ", point)
    new_df = model.transform(ss.createDataFrame([(Vectors.dense(float(point[0]), float(point[1])),)], ['features']))
    new_df.select("prediction").show()
